# -*- coding:utf-8 -*-
# --author： jingfeng 
# time: 2019/5/28


import requests
from lxml import etree
from fake_useragent import UserAgent

requests = requests.Session()

def  login():
    login_url='https://login.51job.com/login.php?lang=c'

    headers={
        'Content-Type':'application/x-www-form-urlencoded',
        'Host':'login.51job.com',
        'Origin':'https://login.51job.com',
        'Referer':'https://login.51job.com/login.php?lang=c',
        'Upgrade-Insecure-Requests':'1',
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36f'
        }
    data ={'lang': 'c',
            'action': 'save',
            'from_domain': 'i',
            'loginname': '17635395714',
            'password': 'czp0927',
            'verifycode':'',
            'isread': 'on'}

    response = requests.post(url=login_url,data=data,headers=headers,
                             allow_redirects=False)

    print(response.status_code)

    url = 'https://i.51job.com/userset/my_51job.php?lang=c'
    response = requests.get(url=url)
    response.encoding =response.apparent_encoding
    print(response.text)
login()